//
//  UConstants.h
//  Medical_Wisdom
//
//  Created by Mac on 14-2-28.
//  Copyright (c) 2014年 Lijie. All rights reserved.
//

#ifndef Medical_Wisdom_UConstants_h
#define Medical_Wisdom_UConstants_h

/******************************************************/

/****  debug log **/ //NSLog输出信息



#define KSERVERADDRESS @"http://push.glavesoft.com"

#ifdef DEBUG

#define DLog( s, ... ) NSLog( @"< %@:(%d) > %@", [[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__, [NSString stringWithFormat:(s), ##__VA_ARGS__] )

#else

#define DLog( s, ... )

#endif


/***  DEBUG RELEASE  */

#if DEBUG

#define MCRelease(x)

#else

#define MCRelease(x)
#define WS(weakSelf)  __weak  __typeof(&*self)weakSelf = self;
#endif

/**************************保存用户的信息*******************/
#define mUserName           @"username"         //用户名
#define mUserNickName       @"userNickname"     //昵称
#define mUserPassword       @"userPassword"     //用户密码
#define mUserID             @"id"           //用户的ID
#define mUserPhone          @"userphone"        //用户联系手机号
#define mRegisterPhone      @"userRegsterPhone"  //用户注册电话
#define mUserToken          @"userToken"        //用户的token
#define mCompanyEmail       @"CompanyEmail"     //客服邮箱
#define mCompanyPhone       @"CompanyPhone"     //客服电话
#define mRegisterId         @"registerid"       //极光推送返回id
#define mDesKey             @"userdeskey"       //DES加密key
#define mLogined            @"userislogined"    //是否已登录
#define mRembered           @"userisremember"   //记住密码
#define mUserInfo           @"userInfo"         //用户信息
#define mIsAllowPush        @"mIsAllowPush"     //是否允许推送
#define mLng                @"mLng"               //经度
#define mLat                @"mLat"               //纬度

#define mEmail              @"email"            //邮箱
#define mIndustries         @"industries"       //行业
#define mIndustries_name    @"industries_name"  //
#define mLogo               @"logo"             //头像
#define mPhone              @"phone"            //手机
#define mProfession         @"profession"       //职业
#define mProfession_name    @"profession_name"  //
#define mQq_num             @"qq_num"           //QQ
#define mSex                @"sex"              //性别
#define mSign               @"sign"             //签名
#define mWx_num             @"wx_num"           //微信
#define FirstLaunch         @"FirstLaunch"      //第一次启动App



#define MSG_ID              @"msg_id"

//声音
#define SOUND               @"SOUND"


#define ChatWidth Main_Screen_Width - 60 - 30*2


#define TabBar_Hide    [[self rdv_tabBarController] setTabBarHidden:YES animated:YES];
#define TabBar_Show    [[self rdv_tabBarController] setTabBarHidden:NO animated:YES];

#define ChatToast       @"ChatToast"

#define GreenColor      mRGBColor(80, 210, 194)
#define TextColorGray   mRGBACOLOR(29, 29, 38 ,0.5)
#define LineColor       mRGBACOLOR(29, 29, 38 ,0.1)
#define TextColorBlack  mRGBColor(29, 29, 38)
#define BackColor  mRGBColor(236, 236, 236)

#define SCREENWIDTN ([UIScreen mainScreen].bounds.size.width)
#define SCREENHEIGHT ([UIScreen mainScreen].bounds.size.height)
#define RGB(r,g,b,a) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a]

/*********************删除消息信息*********/
#define DELETEMESSAGE           @"DeleteMessage"


/**********************AlertInfo***************/
#define SUREYUYUEPARKING_INFO        @"确定预约?"
#define SUREPARKING_INFO            @"确定停车?"
#define LOCKDOWN_INFO               @"车锁已降下，可以停车。"
#define PARKINGFAIL_INFO            @"停车失败"
#define NETERROR_INFO               @"网络故障，请调整网络信号后重新尝试。"
#define TIMEOUT_INFO                @"已有预约超时，请确认？"
#define CANCLEPARKING_INFO                @"您当前已有预约，是否取消当前预约"
#define CANCLEPARKINGYUYUE_INFO           @"您已有预约，是否需要更换预约车位？"
#define CANCLEPARKINGFAIL_INFO      @"取消失败，请联系客服（4000-888-689）处理。"
#define PARKINGJIFEI_INFO           @"您的车正在停车计费中..."
#define PARKINGUSED_INFO            @"车位已被预约或使用。"
#define SURESTOPPARKING_INFO           @"确认结束停车服务？"
#define STOPJIFEISUCCESS_INFO          @"本次停车免费，欢迎您的使用，请给个好评"
#define SURESTOPPARKINGFAIL_INFO           @"停止失败，请确认您的车已驶离车位。"
#define SURESTOPPARKINGFAILTWO_INFO           @"停止失败，请联系客服（4000-888-689）处理。"
#define BLUETOOTHERROR_INFO           @"连接地锁失败，请确保在车位附近后重试"
#define LOCKERROR_INFO           @"该车锁故障，请联系客服（4000-888-689）处理。"
#define JIFENBUGOUPARK_INFO           @"您的信用积分过低，暂时无法停车。"
#define JIFENBUGOUYUYUE_INFO           @"您的信用积分过低，暂时无法预约。"
#define LOCKUNUSED_INFO           @"车锁不存在或停用"
#define USERUNUSED_INFO           @"用户不存在或停用"
#define LOCK_LOCKED_INFO           @"该车位暂不能使用，请30s后重试"
#define SHARELOCKAPPOINMENT_INFO           @"您已预订其他共享车位，无法操作该车位"
#define SHARELOCKPARK_INFO           @"有正在进行的共享停车单"
#define SHARELOCKUP_INFO        @"请确认车辆已完全驶离车位，否则会造成车辆损坏!"


/*****  release   *****/
#define NILRelease [x release], x = nil

#define UIColorMake(r,g,b,a) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a]

#define UIScreenWidth CGRectGetWidth([[UIScreen mainScreen] applicationFrame])
#define UIScreenHeight CGRectGetHeight([[UIScreen mainScreen] applicationFrame])

#pragma mark - Frame(宏 x,y,width,height)
#define KKRGBA(r,g,b,a) [UIColor colorWithRed:(float)r/255.0f green:(float)g/255.0f blue:(float)b/255.0f alpha:a]
#define MainScreenScale [[UIScreen mainScreen]scale] //屏幕的分辨率 当结果为1时，显示的是普通屏幕，结果为2时，显示的是Retian屏幕
// App Frame Height&Width
#define Application_Frame  [[UIScreen mainScreen] applicationFrame] //除去信号区的屏幕的frame
#define APP_Frame_Height   [[UIScreen mainScreen] applicationFrame].size.height //应用程序的屏幕高度
#define App_Frame_Width    [[UIScreen mainScreen] applicationFrame].size.width  //应用程序的屏幕宽度
/*** MainScreen Height Width */
#define Main_Screen_Height [[UIScreen mainScreen] bounds].size.height //主屏幕的高度
#define Main_Screen_Width  [[UIScreen mainScreen] bounds].size.width  //主屏幕的宽度

//比例尺
#define BILI_W Main_Screen_Width/320
//#define BILI_H Main_Screen_Height/480
#define BILI_H Main_Screen_Height/568

#define mAppDelegate        (AppDelegate *)[[UIApplication sharedApplication] delegate]


// @"http://192.168.10.21:8080/Lock/"
//@"http://106.15.203.183:8000/Lock/"

//#define Server_Flag_test//测试
#define Server_Flag_produce//生产

/*---------------------------------------------------------------------------------*/
#if  defined(Server_Flag_test)
//测试
#define Version @"v2"
#define kURL_ClientDomain @"http://192.168.10.21:8080/Lock/"
#elif defined(Server_Flag_produce)
//生产
#define Version @"v2"
#define kURL_ClientDomain @"http://www.5ycl.net:8000/Lock/"//生产
#endif

#define WS(weakSelf)  __weak __typeof(&*self)weakSelf = self;
#define UserDefaults(userdefaults)  NSUserDefaults* userdefaults = [NSUserDefaults standardUserDefaults];


#define IOS7   ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)
#define IOS8  ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)

// View 坐标(x,y)和宽高(width,height)
#define X(v)               (v).frame.origin.x
#define Y(v)               (v).frame.origin.y
#define WIDTH(v)           (v).frame.size.width
#define HEIGHT(v)          (v).frame.size.height

#define MinX(v)            CGRectGetMinX((v).frame) // 获得控件屏幕的x坐标
#define MinY(v)            CGRectGetMinY((v).frame) // 获得控件屏幕的Y坐标

#define MidX(v)            CGRectGetMidX((v).frame) //横坐标加上到控件中点坐标
#define MidY(v)            CGRectGetMidY((v).frame) //纵坐标加上到控件中点坐标

#define MaxX(v)            CGRectGetMaxX((v).frame) //横坐标加上控件的宽度
#define MaxY(v)            CGRectGetMaxY((v).frame) //纵坐标加上控件的高度

#define CONTRLOS_FRAME(x,y,width,height)     CGRectMake(x,y,width,height)

//    系统控件的默认高度
#define kStatusBarHeight   (20.f)
#define kTopBarHeight      (44.f)
#define kBottomBarHeight   (49.f)

#define kCellDefaultHeight (44.f)

// 当控件为全屏时的横纵左边
#define kFrameX             (0.0)
#define kFrameY             (0.0)

#define kPhoneFrameWidth                 (320.0)
#define kPhoneWithStatusNoPhone5Height   (480.0)
#define kPhoneNoWithStatusNoPhone5Height (460.0)
#define kPhoneWithStatusPhone5Height     (568.0)
#define kPhoneNoWithStatusPhone5Height   (548.0)

#define kPadFrameWidth                   (768.0)
#define kPadWithStatusHeight             (1024.0)
#define kPadNoWithStatusHeight           (1004.0)

//中英状态下键盘的高度
#define kEnglishKeyboardHeight  (216.f)
#define kChineseKeyboardHeight  (252.f)

#pragma mark - Funtion Method (宏 方法)
//PNG JPG 图片路径
#define PNGPATH(NAME)          [[NSBundle mainBundle] pathForResource:[NSString stringWithUTF8String:NAME] ofType:@"png"]
#define JPGPATH(NAME)          [[NSBundle mainBundle] pathForResource:[NSString stringWithUTF8String:NAME] ofType:@"jpg"]
#define PATH(NAME,EXT)         [[NSBundle mainBundle] pathForResource:(NAME) ofType:(EXT)]

//加载图片
#define PNGIMAGE(NAME)         [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:(NAME) ofType:@"png"]]
#define JPGIMAGE(NAME)         [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:(NAME) ofType:@"jpg"]]
#define IMAGE(NAME,EXT)        [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:(NAME) ofType:(EXT)]]
#define IMAGENAMED(NAME)       [UIImage imageNamed:NAME]

//字体大小（常规/粗体）
#define BOLDSYSTEMFONT(FONTSIZE) [UIFont boldSystemFontOfSize:FONTSIZE]
#define SYSTEMFONT(FONTSIZE)     [UIFont systemFontOfSize:FONTSIZE]
#define FONT(NAME,FONTSIZE)      [UIFont fontWithName:(NAME) size:(FONTSIZE)]

//颜色（RGB）
#define mRGBColor(r,g,b)          [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:1]
#define mRGBACOLOR(r,g,b,a)       [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:(a)]

//当前版本
#define FSystenVersion            ([[[UIDevice currentDevice] systemVersion] floatValue])
#define DSystenVersion            ([[[UIDevice currentDevice] systemVersion] doubleValue])
#define SSystemVersion            ([[UIDevice currentDevice] systemVersion])

//当前语言
#define CURRENTLANGUAGE           ([[NSLocale preferredLanguages] objectAtIndex:0])


//是否Retina屏
#define isRetina                  ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 960), [[UIScreen mainScreen] currentMode].size) :NO)
//是否iPhone5
#define ISIPHONE                  [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone
#define ISIPHONE5                 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) : NO)

#define ISIPHONE4                 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 960), [[UIScreen mainScreen] currentMode].size) : NO)

//是否是iPad
#define isPad                      (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)


// UIView - viewWithTag 通过tag值获得子视图
#define VIEWWITHTAG(_OBJECT,_TAG)   [_OBJECT viewWithTag : _TAG]

//应用程序的名字
#define AppDisplayName              [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"]

//RGB颜色转换（16进制->10进制）
#define UIColorFromRGB(rgbValue)    [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]

//判断设备室真机还是模拟器
#if TARGET_OS_IPHONE
/** iPhone Device */
#endif

#if TARGET_IPHONE_SIMULATOR
/** iPhone Simulator */
#endif

#endif
